//
//  HWRequestLogManage
//
//  Created by 李含文 on 2021/4/28.
//  Copyright © 2021 MINISO. All rights reserved.
//

/* 使用案例
 在AppDelegate中 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中创建window成功 后调用如下方法
 
 - (void)openRequestLogManage {
     HWRequestLogManage.shared.successBlock = ^BOOL(id  _Nonnull responseObject) { // responseObject类似AFN中请求成功返回的 响应体
         if (responseObject && responseObject[@"code"]) { // 如果responseObject存在 并且responseObject[@"code"存在
             NSString *code = responseObject[@"code"];
             return code.integerValue == 200?YES:NO; // 如果code是200 说明服务器返回请求成功 反之
         }
         return YES;
     };
     [HWRequestLogManage shared].onlyURLs = @[@"baidu.com"]; // 只拦截域名包含 baidu.com 的请求
     [[HWRequestLogManage shared] openWithWindow:self.window]; //开启
 }
 */

#import <Foundation/Foundation.h>

static NSInteger const success_Code = 200; // 返回成功后的code 如果返回不一样直接项目内搜索success_Code 字段修改相关逻辑

NS_ASSUME_NONNULL_BEGIN

@interface HWRequestLogManage : NSObject

/// 当前window
@property (nonatomic, weak, readonly) UIWindow *window;
/// 设置只抓取的域名,忽略大小写,默认抓取所有
@property (nonatomic, strong) NSArray<NSString *> *onlyURLs;

/// 请求成功条件block事件
@property (nonatomic, copy) BOOL(^successBlock)(id responseObject);

+ (HWRequestLogManage *)shared;

/// 开启日志工具(注意:需要在window创建成功后调用)
- (void)openWithWindow:(UIWindow *)window;

/// 禁用
- (void)disable;

/// 获取当前显示的栈顶控制器
- (void)getVisibleViewController:(void(^)(UIViewController *vc))action;
@end

NS_ASSUME_NONNULL_END
